package com.ruoyi.consumer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.consumer.domain.CStatisticSumTable;
import com.ruoyi.consumer.service.ICStatisticSumTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 统计SUMController
 * 
 * @author YFENTEST
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/consumer/table")
public class CStatisticSumTableController extends BaseController
{
    @Autowired
    private ICStatisticSumTableService cStatisticSumTableService;

    /**
     * 查询统计SUM列表
     */
    @PreAuthorize("@ss.hasPermi('consumer:table:list')")
    @GetMapping("/list")
    public TableDataInfo list(CStatisticSumTable cStatisticSumTable)
    {
        startPage();
        List<CStatisticSumTable> list = cStatisticSumTableService.selectCStatisticSumTableList(cStatisticSumTable);
        return getDataTable(list);
    }

    /**
     * 导出统计SUM列表
     */
    @PreAuthorize("@ss.hasPermi('consumer:table:export')")
    @Log(title = "统计SUM", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CStatisticSumTable cStatisticSumTable)
    {
        List<CStatisticSumTable> list = cStatisticSumTableService.selectCStatisticSumTableList(cStatisticSumTable);
        ExcelUtil<CStatisticSumTable> util = new ExcelUtil<CStatisticSumTable>(CStatisticSumTable.class);
        util.exportExcel(response, list, "统计SUM数据");
    }

    /**
     * 获取统计SUM详细信息
     */
    @PreAuthorize("@ss.hasPermi('consumer:table:query')")
    @GetMapping(value = "/{statisticId}")
    public AjaxResult getInfo(@PathVariable("statisticId") Integer statisticId)
    {
        return success(cStatisticSumTableService.selectCStatisticSumTableByStatisticId(statisticId));
    }

    /**
     * 新增统计SUM
     */
    @PreAuthorize("@ss.hasPermi('consumer:table:add')")
    @Log(title = "统计SUM", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CStatisticSumTable cStatisticSumTable)
    {
        return toAjax(cStatisticSumTableService.insertCStatisticSumTable(cStatisticSumTable));
    }

    /**
     * 修改统计SUM
     */
    @PreAuthorize("@ss.hasPermi('consumer:table:edit')")
    @Log(title = "统计SUM", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CStatisticSumTable cStatisticSumTable)
    {
        return toAjax(cStatisticSumTableService.updateCStatisticSumTable(cStatisticSumTable));
    }

    /**
     * 删除统计SUM
     */
    @PreAuthorize("@ss.hasPermi('consumer:table:remove')")
    @Log(title = "统计SUM", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statisticIds}")
    public AjaxResult remove(@PathVariable Integer[] statisticIds)
    {
        return toAjax(cStatisticSumTableService.deleteCStatisticSumTableByStatisticIds(statisticIds));
    }
}
